package com.podium.web.system.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.podium.comment.validation.annotation.Email;
import com.podium.comment.validation.annotation.Password;
import com.podium.comment.validation.annotation.Phone;
import com.podium.comment.validation.groups.CreateGroup;
import com.podium.comment.validation.groups.UpdateGroup;
import jakarta.validation.constraints.NotBlank;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;
import java.util.Set;

/**
 * @author 邵文泽
 * @description 系统用户
 * @date Mon Apr 28 16:21:15 CST 2025
 */
@Getter
@Setter
@jakarta.validation.constraints.Email
@TableName("sys_user")
public class SysUser {

    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;


    /**
     * 用户名
     */
    @TableField("username")
    @NotBlank(message = "请输入用户名！",groups = {CreateGroup.class, UpdateGroup.class})
    private String username;


    /**
     * 密码
     */
    @TableField("password")
    @NotBlank(message = "请输入密码！",groups = {CreateGroup.class})
    @Password(groups = CreateGroup.class)
    private String password;


    /**
     * 昵称
     */
    @TableField("nick_name")
    @NotBlank(message = "请输入昵称！",groups = {CreateGroup.class, UpdateGroup.class})
    private String nickName;


    /**
     * 电话
     */
    @TableField("phone")
    @NotBlank(message = "请输入电话！",groups = {CreateGroup.class, UpdateGroup.class})
    @Phone(groups = {CreateGroup.class, UpdateGroup.class})
    private String phone;


    /**
     * 邮箱
     */
    @TableField("email")
    @Email(groups = {CreateGroup.class, UpdateGroup.class})
    private String email;


    /**
     * 居住地址
     */
    @TableField("address")
    private String address;


    /**
     * 头像
     */
    @TableField("profile_picture")
    private String profilePicture;


    /**
     * 是否删除 0 正常 1 删除
     */
    @TableField("del_flag")
    private Long delFlag;


    /**
     * 创建人名称
     */
    @TableField("create_by")
    private String createBy;


    /**
     * 创建时间
     */
    @TableField("create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;


    /**
     * 修改人名称
     */
    @TableField("update_by")
    private String updateBy;


    /**
     * 修改时间
     */
    @TableField("update_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    /**
     * 角色列表
     */
    @TableField(exist = false)
    private Set<String> roles;


    /**
     * 权限列表
     */
    @TableField(exist = false)
    private Set<String> permissions;

}